package com.lianzhihui.romeex.adapter;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.MyTeamBean;
import com.lianzhihui.romeex.utils.DateUtil;

import java.util.List;

/**
 * Description: 主页适配器
 * Author: RAMON
 * CreateDate: 2020/11/4 8:10 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class MyTeamActivityAdapter extends BaseQuickAdapter<MyTeamBean.ChildInfoBean.DirectList, BaseViewHolder> {

    Context mContext;

    public MyTeamActivityAdapter(@Nullable Context mContext, @Nullable List<MyTeamBean.ChildInfoBean.DirectList> data) {
        super(R.layout.item_my_team_layout, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MyTeamBean.ChildInfoBean.DirectList item) {

        helper.setText(R.id.tv_user_id, item.getWalletAddress())
                .setText(R.id.reward, "TA邀请的有效用户" + item.getChildValidCount() + "人")
                .setText(R.id.time, DateUtil.sec2Date(item.getTimestamp()));
        TextView isGrant = helper.getView(R.id.isGrant);
        if (item.getValidStatus() == 1) {
            //1 无效
            isGrant.setText("无效");
            isGrant.setTextColor(mContext.getResources().getColor(R.color.text_cccccc_color));
            isGrant.setBackgroundResource(R.drawable.tv_stoke_cccccc_25dp);
        } else {
            //2 有效
            isGrant.setText("有效");
            isGrant.setTextColor(mContext.getResources().getColor(R.color.text_F3863B_color));
            isGrant.setBackgroundResource(R.drawable.tv_stoke_f3863b_25dp);
        }
    }
}
